thereby hangs a tale

That detail or incident reminds one of another story, as in So he went without supper, but thereby hangs a tale. This expression, embodying the pun on tail and tale, was used by Shakespeare in at least four of his plays and presumably was well known before that. [ 1500s ]